<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="__PUBLIC__/Admin/lib/html5.js"></script>
<script type="text/javascript" src="__PUBLIC__/Admin/lib/respond.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/Admin/lib/PIE_IE678.js"></script>
<![endif]-->
<link href="__PUBLIC__/Admin/css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="__PUBLIC__/Admin/css/H-ui.admin.css" rel="stylesheet" type="text/css" />
<link href="__PUBLIC__/Admin/lib/icheck/icheck.css" rel="stylesheet" type="text/css" />
<link href="__PUBLIC__/Admin/css/style.css" rel="stylesheet" type="text/css" />
<link href="__PUBLIC__/Admin/lib/Hui-iconfont/1.0.1/iconfont.css" rel="stylesheet" type="text/css" />
<link href="__PUBLIC__/Admin/lib/webuploader/0.1.5/webuploader.css" rel="stylesheet" type="text/css" />
<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>新增图片</title>
</head>
<body>
<div class="pd-20">
	<form action="__URL__/addImage" method="post" enctype="multipart/form-data" class="form form-horizontal" id="form-article-add">
		<div class="row cl">
			<label class="form-label col-2"><span class="c-red">*</span>图片标题：</label>
			<div class="formControls col-10">
				<input type="text" class="input-text" value="{$data['title']}" name="title">
				<if condition="$Think.get.id neq ''">
					<input type="hidden" class="input-text" name="id" value="{$Think.get.id}" >
				</if>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-2">简略标题：</label>
			<div class="formControls col-10">
				<input type="text" class="input-text" value="{$data['mintitle']}" placeholder="" id="" name="min-title">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-2"><span class="c-red">*</span>相册群组：</label>
			<div class="formControls col-2"> <span class="select-box">
				<select name="p_group" class="select">
					<option value="0">全部栏目</option>
					{$cate}
				</select>
				</span> </div>
		</div>
		<div class="row cl">
			<label class="form-label col-2">排序：</label>
			<div class="formControls col-2">
				<input type="text" class="input-text" value="{$data['sort']}" placeholder="" id="" name="sort_">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-2">关键词：</label>
			<div class="formControls col-10">
				<input type="text" class="input-text" value="{$data['key_word']}" placeholder="" id="" name="key_word">
			</div>
		</div>
		<div class="row cl">
            <label class="form-label col-2">上传图片：</label>
            <div class="formControls col-10">
            <div class="upload">
                <div class="upload-wrapper">
                 <div class="upload-file-list" id="file-list">

                 </div>
                 <div class="upload-satus">已选择 <span>0</span> 张 <div class="upload-total"><span><i class="c1"></i>jpg：<b></b></span><span><i class="c2"></i>png: <b>0</b></span><span><i class="c3"></i>gif: <b>0</b></span></div></div>
                </div>
                 <div class="upload-btn">选择图片
                     <input type="file" onchange="selectfile(this)" name="filepic[]">
                 </div>
            </div>
            </div>
		</div>
		<div class="row cl">
			<div class="col-10 col-offset-2">
				<button onClick="article_save_submit();" class="btn btn-primary radius" type="submit"><i class="Hui-iconfont">&#xe632;</i> 保存并提交审核</button>
				<button onClick="article_save();" class="btn btn-secondary radius" type="button"><i class="Hui-iconfont">&#xe632;</i> 保存草稿</button>
				<button onClick="layer_close();" class="btn btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
			</div>
		</div>
	</form>
</div>
</div>
<script type="text/javascript" src="__PUBLIC__/Admin/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/Admin/js/H-ui.js"></script>
<script type="text/javascript" src="__PUBLIC__/Admin/js/H-ui.admin.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/baseCommon.js"></script>
<script src="__PUBLIC__/js/startmove.js"></script>
<script type="text/javascript">
  // 更新状态
  function updataStatus(data){
	  var upload_satus_total = document.getElementsByClassName('upload-satus')[0].getElementsByTagName('span')[0];
	  var upload_satus_totalb = document.getElementsByClassName('upload-total')[0].getElementsByTagName('b');
	  upload_satus_total.innerHTML = data['jpg']+data['png']+data['gif'];
	  upload_satus_totalb[0].innerHTML = data['jpg'];
	  upload_satus_totalb[1].innerHTML = data['png'];
	  upload_satus_totalb[2].innerHTML = data['gif'];
  }
  var is_upload = false;
  var index = 1;
  var fixarr = [];
  fixarr['jpg'] = 0;
  fixarr['png'] = 0;
  fixarr['gif'] = 0;
  //选择文件
  function selectfile(obj){
	   var file = obj.value;
	   var fix = subfix(file);
	   if(is_allowType(fix)){
		     fixarr[fix]+=1;
		     var upload_wrapper = document.getElementsByClassName('upload-wrapper')[0];
		     updataStatus(fixarr);
		     var filelist = document.getElementById('file-list');
		     var fileview = document.createElement('div');
		     var fileInp = document.createElement("input");
		     var upload_btn = document.getElementsByClassName("upload-btn")[0];
		     if(!is_upload){
				  upload_wrapper.style.display = 'block';
			 }
		     is_upload = true;
		     fileInp.type = 'file';
		     fileInp.name = 'filepic[]';
		     fileInp.setAttribute("onchange","selectfile(this)");
		     fileInp.setAttribute("index",index);
		     upload_btn.appendChild(fileInp);
		     fileview.setAttribute("index",index)
		     fileview.className = 'file-pic-item';
		     preview(obj,fileview);
		     fileview.setAttribute("onmouseover","createLay(this)");
		     filelist.appendChild(fileview);
		     //创建删除层
		     index++;
	   }else{

		    var upload_satus_total = document.getElementsByClassName('upload-satus')[0];
		    var error_tips = document.createElement("p");
		    error_tips.innerHTML = "上传文件不允许";
		    upload_satus_total.appendChild(error_tips);
		    Move(error_tips,'opacity',100);
		    setTimeout(function(){
				Move(error_tips,'opacity',1);
				setTimeout(function(){
					upload_satus_total.removeChild(error_tips);
				},800)
			},2000)
	   }
  }

  //创建删除层
  function createLay(obj){
	    var isCreate = obj.getAttribute("isCreate");
	    if(isCreate){
			 return;
		}
	    obj.setAttribute("isCreate",true);
	    var createLay = document.createElement("div");
	    createLay.className = "img-lay";
	    createLay.innerHTML = '<a href="javascript:;" onclick="delImage(this)"></a>'
	    obj.appendChild(createLay);
  }

  //删除预览图
  function delImage(obj){

	   var parent = obj.parentNode.parentNode;
	   var index = parent.getAttribute('index');
	   var fileBtnWrap = document.getElementsByClassName("upload-btn")[0];
	   var filepicitem = document.getElementById('file-list');
	   var FileList = fileBtnWrap.getElementsByTagName('input');
	   filepicitem.removeChild(parent);

	   for(var i=0;i<FileList.length;i++){
		     Findex = FileList[i].getAttribute("index");
		     if(Findex==index){
				   var FileFix = subfix(FileList[i].value);
				   fixarr[FileFix]-=1;
				   fileBtnWrap.removeChild(FileList[i]);
			 }
	   }
	  updataStatus(fixarr);
  }
</script>
</body>
</html>